home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / penguin.swf / scripts / __Packages / Class / Role.as < prev   
Encoding:
Text File  |  2007-06-26  |  1.9 KB  |  94 lines

  1. class Class.Role extends MovieClip
  2. {
  3.    var _life;
  4.    var life;
  5.    var damage;
  6.    var hurtObj;
  7.    var opp;
  8.    var mc;
  9.    var onEnterFrame;
  10.    var x;
  11.    var isCPU = false;
  12.    var inLose = false;
  13.    function Role()
  14.    {
  15.       super();
  16.       this._life = 100;
  17.       this.life = this._life;
  18.       this.damage = 50;
  19.       this.hurtObj = new Object();
  20.    }
  21.    function init(_opp)
  22.    {
  23.       this.opp = _opp;
  24.    }
  25.    function setReady()
  26.    {
  27.       this.gotoAndStop("ready");
  28.    }
  29.    function setStand()
  30.    {
  31.       this.gotoAndStop("stand");
  32.    }
  33.    function setAnimation(powerRate)
  34.    {
  35.       var _loc2_ = int(powerRate * this.mc._totalframes) + 1;
  36.       if(_loc2_ > this.mc._totalframes)
  37.       {
  38.          _loc2_ = this.mc._totalframes;
  39.       }
  40.       this.mc.gotoAndStop(_loc2_);
  41.    }
  42.    function startShoot()
  43.    {
  44.       trace("startShoot: " + this.startShoot);
  45.       this.gotoAndPlay("shoot");
  46.       _root.soundStart("shoot1_snd");
  47.    }
  48.    function hit(type, damageRate)
  49.    {
  50.       this.gotoAndPlay("h" + type);
  51.       this.hurtObj["hurt" + type] = true;
  52.       this.life -= int(this.damage * damageRate - Math.random() * 4);
  53.       if(this.life < 0)
  54.       {
  55.          this.life = 0;
  56.       }
  57.       _root.UI_mc.setHP(this,this.life);
  58.       if(this.isCPU && this.opp.isCPU != true)
  59.       {
  60.          _root.setScore(int(100 * damageRate),"vs");
  61.       }
  62.       if(this.life <= 0)
  63.       {
  64.          this.lose();
  65.       }
  66.       _root.soundStart("hit1_snd");
  67.    }
  68.    function checkHurt(mc)
  69.    {
  70.       if(this.hurtObj[mc._name] == true)
  71.       {
  72.          mc._visible = true;
  73.       }
  74.    }
  75.    function lose()
  76.    {
  77.       this.inLose = true;
  78.       this.gotoAndStop("lose");
  79.    }
  80.    function hitBack(Vx)
  81.    {
  82.       this.onEnterFrame = function()
  83.       {
  84.          this.x += Vx;
  85.          Vx *= 0.9;
  86.          _root.mc.make3D(this);
  87.          if(Vx < 1)
  88.          {
  89.             delete this.onEnterFrame;
  90.          }
  91.       };
  92.    }
  93. }
  94.